package com.huluobo.a2109amvvmdemo.databindnig;

import com.huluobo.a2109amvvmdemo.databinding.ActivityUserBinding;
import com.huluobo.a2109amvvmdemo.viewbinding.BaseActivity;

public class UserActivity extends BaseActivity<ActivityUserBinding> {

    @Override
    protected void initData() {

    }

    @Override
    protected void initView() {
        viewBinding.btnUserConfirm.setOnClickListener(v -> {
            User user = getUser();
//           viewBinding.tvUserName.setText(user.getUserName());
//            viewBinding.tvUserId.setText(user.getUserId());
            viewBinding.setUser123(user);
        });
    }

    private User getUser() {
        return new User(getUserId(), getUserName());
    }

    private String getUserId() {
        return viewBinding.edUserId.getText().toString();
    }

    private String getUserName() {
        return viewBinding.edUserName.getText().toString();
    }

    @Override
    protected ActivityUserBinding getViewBinding() {
        return ActivityUserBinding.inflate(getLayoutInflater());
    }
}